home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / thesrc10.zip / COMM5.C < prev    next >
C/C++ Source or Header  |  1992-08-10  |  29KB  |  1,093 lines

  1. /***********************************************************************/
  2. /* COMM5.C - Commands T-Z                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991,1992 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@itc.gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 7877
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42.  
  43. #include "the.h"
  44.  
  45. /*#define DEBUG 1*/
  46.  
  47. /*-------------------------- external data ----------------------------*/
  48. extern LINE *next_line,*curr_line;
  49. extern VIEW_DETAILS *vd_current,*vd_first;
  50. extern char current_screen;
  51. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  52. extern char current_file;         /* pointer to current file */
  53. extern WINDOW *foot,*error_window;
  54. extern char error_on_screen;
  55. extern unsigned char *rec;
  56. extern unsigned short rec_len;
  57. extern unsigned char mode_insert;        /* defines insert mode toggle */
  58. extern unsigned char in_profile;    /* indicates if processing profile */
  59. /*---------------------- function definitions -------------------------*/
  60. #ifdef PROTO
  61. void split_command(unsigned char *,unsigned char *,unsigned char *);
  62. int param_split(unsigned char *,unsigned char *[],int );
  63. long valid_target(unsigned char *);
  64. int get_row_for_focus_line(int,long,long);
  65. #else
  66. void split_command();
  67. int param_split();
  68. long valid_target();
  69. int get_row_for_focus_line();
  70. #endif
  71. /*man-start*********************************************************************
  72. COMMAND
  73.      tabcmd - switch windows (main/prefix command) for the current file
  74.  
  75. SYNTAX
  76.      ** effective only if bound to a key **
  77.  
  78. DESCRIPTION
  79.      The TABCMD command switches the focus of the editor from the
  80.      main or prefix windows to the command line and vice versa, depending
  81.      on which window is currently active.
  82.  
  83. COMPATIBILITY
  84.      Compatible.
  85.  
  86. SEE ALSO
  87.      tabpre
  88.  
  89. STATUS
  90.      Complete.
  91. **man-end**********************************************************************/
  92. #ifdef PROTO
  93. int Tabcmd(unsigned char *params)
  94. #else
  95. int Tabcmd(params)
  96. unsigned char *params;
  97. #endif
  98. /***********************************************************************/
  99. {
  100. /*--------------------------- local data ------------------------------*/
  101.  unsigned char last_win;
  102.  unsigned short x,y;
  103. /*--------------------------- processing ------------------------------*/
  104. #ifdef TRACE
  105.  trace_function("comm5.c:   Tabcmd");
  106. #endif
  107.  last_win = CURRENT_VIEW->previous_window;
  108.  CURRENT_VIEW->previous_window =
  109.               CURRENT_VIEW->current_window;
  110.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  111.     {
  112.      post_process_line(CURRENT_VIEW->focus_line);
  113.      CURRENT_VIEW->current_window = WINDOW_COMMAND;
  114.      wmove(CURRENT_WINDOW,0,0);
  115.     }
  116.  else
  117.     {
  118.      pre_process_line(CURRENT_VIEW->focus_line);
  119.      CURRENT_VIEW->current_window = last_win;
  120.      getyx(CURRENT_WINDOW,y,x);
  121.      y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  122.                                 CURRENT_VIEW->focus_line,
  123.                                 CURRENT_VIEW->current_line);
  124.      wmove(CURRENT_WINDOW,y,x);
  125.     }
  126. #ifdef TRACE
  127.  trace_return();
  128. #endif
  129.  return(OK);
  130. }
  131. /*man-start*********************************************************************
  132. COMMAND
  133.      tabkey - set characteristics of the tab key
  134.  
  135. SYNTAX
  136.      TABKey Insert|Overstrike|Both Tab|Character
  137.  
  138. DESCRIPTION
  139.      The TABKEY sets the action to be taken when the tab key is hit.
  140.      Depending on the insert mode, the tab key will either display
  141.      a raw tab character or will move to the next tab column.
  142.  
  143. COMPATIBILITY
  144.      New function.
  145.  
  146. DEFAULT
  147.      INSERT CHARACTER, OVERSTRIKE TAB
  148.  
  149. STATUS
  150.      Complete
  151. **man-end**********************************************************************/
  152. #ifdef PROTO
  153. int Tabkey(unsigned char *params)
  154. #else
  155. int Tabkey(params)
  156. unsigned char *params;
  157. #endif
  158. /***********************************************************************/
  159. {
  160. /*--------------------------- extern data -----------------------------*/
  161. /*--------------------------- local data ------------------------------*/
  162. #define TKY_PARAMS  2
  163.  unsigned char *word[TKY_PARAMS+1];
  164.  char parm[TKY_PARAMS];
  165.  register int i;
  166.  unsigned short num_params;
  167. /*--------------------------- processing ------------------------------*/
  168. #ifdef TRACE
  169.  trace_function("comm5.c:   Tabkey");
  170. #endif
  171.  num_params = param_split(params,word,TKY_PARAMS);
  172.  
  173.  for (i=0;i<TKY_PARAMS;i++)
  174.      parm[i] = UNDEFINED_OPERAND;
  175.  if (equal("insert",word[0],1))
  176.     parm[0] = 'I';
  177.  if (equal("overwrite",word[0],1))
  178.     parm[0] = 'O';
  179.  if (equal("both",word[0],1))
  180.     parm[0] = 'B';
  181.  if (parm[0] == UNDEFINED_OPERAND)
  182.    {
  183.     display_error(1,word[0]);
  184. #ifdef TRACE
  185.     trace_return();
  186. #endif
  187.     return(ERROR);
  188.    }
  189.  if (equal("tab",word[1],1))
  190.     parm[1] = 'T';
  191.  if (equal("character",word[1],1))
  192.     parm[1] = 'C';
  193.  if (parm[1] == UNDEFINED_OPERAND)
  194.    {
  195.     display_error(1,word[1]);
  196. #ifdef TRACE
  197.     trace_return();
  198. #endif
  199.     return(ERROR);
  200.    }
  201.  switch(parm[0])
  202.     {
  203.      case 'B':
  204.               tabkey_insert = parm[1];
  205.               tabkey_overwrite = parm[1];
  206.               break;
  207.      case 'I':
  208.               tabkey_insert = parm[1];
  209.               break;
  210.      case 'O':
  211.               tabkey_overwrite = parm[1];
  212.               break;
  213.     }
  214. #ifdef TRACE
  215.  trace_return();
  216. #endif
  217.  return(OK);
  218. }
  219. /*man-start*********************************************************************
  220. COMMAND
  221.      tabpre - switch windows (main prefix) for the current file
  222.  
  223. SYNTAX
  224.      ** effective only if bound to a key **
  225.  
  226. DESCRIPTION
  227.      The TABPRE command switches the focus of the editor from the
  228.      main window to the prefix window and vice versa, depending
  229.      on which window is currently active.
  230.  
  231. COMPATIBILITY
  232.      Compatible.
  233.  
  234. SEE ALSO
  235.      tabcmd
  236.  
  237. STATUS
  238.      Complete.
  239. **man-end**********************************************************************/
  240. #ifdef PROTO
  241. int Tabpre(unsigned char *params)
  242. #else
  243. int Tabpre(params)
  244. unsigned char *params;
  245. #endif
  246. /***********************************************************************/
  247. {
  248. /*--------------------------- local data ------------------------------*/
  249.  unsigned char last_win;
  250.  unsigned short y,x;
  251. /*--------------------------- processing ------------------------------*/
  252. #ifdef TRACE
  253.  trace_function("comm5.c:   Tabpre");
  254. #endif
  255.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  256.    {
  257. #ifdef TRACE
  258.     trace_return();
  259. #endif
  260.     return(OK);
  261.    }
  262.  
  263.  getyx(CURRENT_WINDOW,y,x);
  264.  
  265.  last_win = CURRENT_VIEW->previous_window;
  266.  CURRENT_VIEW->previous_window =
  267.               CURRENT_VIEW->current_window;
  268.  if (CURRENT_VIEW->current_window == WINDOW_MAIN)
  269.    {
  270.     post_process_line(CURRENT_VIEW->focus_line);
  271.     CURRENT_VIEW->current_window = WINDOW_PREFIX;
  272.    }
  273.  else
  274.    {
  275.     pre_process_line(CURRENT_VIEW->focus_line);
  276.     CURRENT_VIEW->current_window = WINDOW_MAIN;
  277.    }
  278.  wmove(CURRENT_WINDOW,y,0);
  279. #ifdef TRACE
  280.  trace_return();
  281. #endif
  282.  return(OK);
  283. }
  284. /*man-start*********************************************************************
  285. COMMAND
  286.      tabs - set tab length for TAB key
  287.  
  288. SYNTAX
  289.      TABS INCR n
  290.  
  291. DESCRIPTION
  292.      The TABS command determines the position of tab columns when the
  293.      TAB key is pressed.
  294.  
  295. COMPATIBILITY
  296.      Does not support specification of actual tab columns.
  297.  
  298. SEE ALSO
  299.      sos_tabf
  300.  
  301. STATUS
  302.      Complete.
  303. **man-end**********************************************************************/
  304. #ifdef PROTO
  305. int Tabs(unsigned char *params)
  306. #else
  307. int Tabs(params)
  308. unsigned char *params;
  309. #endif
  310. /***********************************************************************/
  311. {
  312. /*--------------------------- extern data -----------------------------*/
  313. extern unsigned char TABSx;
  314. /*--------------------------- local data ------------------------------*/
  315. #define TABS_PARAMS  2
  316.  unsigned char *word[TABS_PARAMS+1];
  317.  char parm[TABS_PARAMS];
  318.  register int i;
  319.  unsigned short num_params;
  320.  unsigned short x,y;
  321.  char pre_col;
  322.  short rc;
  323. /*--------------------------- processing ------------------------------*/
  324. #ifdef TRACE
  325.  trace_function("comm5.c:   Tabs");
  326. #endif
  327.  num_params = param_split(params,word,TABS_PARAMS);
  328.  for (i=0;i<TABS_PARAMS;i++)
  329.      parm[0] = UNDEFINED_OPERAND;
  330.  if (equal("incr",word[0],2))
  331.     parm[0] = TRUE;
  332.  if (parm[0] == UNDEFINED_OPERAND)
  333.    {
  334.     display_error(1,word[0]);
  335. #ifdef TRACE
  336.     trace_return();
  337. #endif
  338.     return(OK);
  339.    }
  340.  if (!valid_positive_integer(word[1]))
  341.    {
  342.     display_error(4,word[1]);
  343. #ifdef TRACE
  344.     trace_return();
  345. #endif
  346.     return(OK);
  347.    }
  348.  parm[1] = (char)atoi(word[1]);
  349.  if (parm[1] < 1)
  350.    {
  351.     display_error(5,word[1]);
  352. #ifdef TRACE
  353.     trace_return();
  354. #endif
  355.     return(OK);
  356.    }
  357.  if (parm[1] > 32)
  358.    {
  359.     display_error(6,word[1]);
  360. #ifdef TRACE
  361.     trace_return();
  362. #endif
  363.     return(OK);
  364.    }
  365.  if (in_profile)
  366.     TABSx = parm[1];
  367.  else
  368.     CURRENT_VIEW->tabs = parm[1];
  369. #ifdef TRACE
  370.  trace_return();
  371. #endif
  372.  return(OK);
  373. }
  374. /*man-start*********************************************************************
  375. COMMAND
  376.      tabsin - set tab processing on file input
  377.  
  378. SYNTAX
  379.      TABSIn ON|OFF [n]
  380.  
  381. DESCRIPTION
  382.      The TABSIN command determines if tabs read from a file are to be
  383.      expanded to spaces and if so how many spaces.
  384.  
  385. COMPATIBILITY
  386.      Does not support TABQUOTE option.
  387.  
  388. SEE ALSO
  389.      tabsout
  390.  
  391. STATUS
  392.      Complete.
  393. **man-end**********************************************************************/
  394. #ifdef PROTO
  395. int Tabsin(unsigned char *params)
  396. #else
  397. int Tabsin(params)
  398. unsigned char *params;
  399. #endif
  400. /***********************************************************************/
  401. {
  402. /*---------------------------------------------------------------------*/
  403. /* The settings for TABSIN is a global value, despite it supposedly    */
  404. /* being a file level value.                                           */
  405. /*---------------------------------------------------------------------*/
  406. /*--------------------------- extern data -----------------------------*/
  407. extern unsigned char TABI_ONx;
  408. extern unsigned char TABI_Nx;
  409. /*--------------------------- local data ------------------------------*/
  410. #define TABI_PARAMS  2
  411.  unsigned char *word[TABI_PARAMS+1];
  412.  char parm[TABI_PARAMS];
  413.  register int i;
  414.  unsigned short num_params;
  415.  unsigned short x,y;
  416.  char pre_col;
  417.  short rc;
  418. /*--------------------------- processing ------------------------------*/
  419. #ifdef TRACE
  420.  trace_function("comm5.c:   Tabsin");
  421. #endif
  422.  num_params = param_split(params,word,TABI_PARAMS);
  423.  for (i=0;i<TABI_PARAMS;i++)
  424.      parm[0] = UNDEFINED_OPERAND;
  425.  if (equal("on",word[0],2))
  426.     parm[0] = TRUE;
  427.  if (equal("off",word[0],3))
  428.     parm[0] = FALSE;
  429.  if (parm[0] == UNDEFINED_OPERAND)
  430.    {
  431.     display_error(1,word[0]);
  432. #ifdef TRACE
  433.     trace_return();
  434. #endif
  435.     return(OK);
  436.    }
  437.  switch(parm[0])
  438.     {
  439.      case TRUE:
  440.          if (!valid_positive_integer(word[1]))
  441.            {
  442.             display_error(4,word[1]);
  443. #ifdef TRACE
  444.             trace_return();
  445. #endif
  446.             return(OK);
  447.            }
  448.          parm[1] = (char)atoi(word[1]);
  449.          break;
  450.      case FALSE:
  451.          if (strcmp(word[1],"") != 0)
  452.            {
  453.             display_error(1,word[1]);
  454. #ifdef TRACE
  455.             trace_return();
  456. #endif
  457.             return(OK);
  458.            }
  459.          break;
  460.     }
  461.  if (parm[0])
  462.    {
  463.     if (parm[1] < 1)
  464.       {
  465.        display_error(5,word[1]);
  466. #ifdef TRACE
  467.        trace_return();
  468. #endif
  469.        return(OK);
  470.       }
  471.     if (parm[1] > 32)
  472.       {
  473.        display_error(6,word[1]);
  474. #ifdef TRACE
  475.        trace_return();
  476. #endif
  477.        return(OK);
  478.       }
  479.    }
  480.  TABI_ONx = parm[0];
  481.  TABI_Nx = parm[1];
  482.  
  483. #ifdef TRACE
  484.  trace_return();
  485. #endif
  486.  return(OK);
  487. }
  488. /*man-start*********************************************************************
  489. COMMAND
  490.      tabsout - set tab processing on file output
  491.  
  492. SYNTAX
  493.      TABSOut ON|OFF [n]
  494.  
  495. DESCRIPTION
  496.      The TABSOUT command determines if spaces written to a file are to be
  497.      compressed to tabs and if so how many spaces.
  498.  
  499. COMPATIBILITY
  500.      Compatible.
  501.  
  502. SEE ALSO
  503.      tabsin
  504.  
  505. STATUS
  506.      Complete.
  507. **man-end**********************************************************************/
  508. #ifdef PROTO
  509. int Tabsout(unsigned char *params)
  510. #else
  511. int Tabsout(params)
  512. unsigned char *params;
  513. #endif
  514. /***********************************************************************/
  515. {
  516. /*--------------------------- extern data -----------------------------*/
  517. extern unsigned char TABO_ONx;
  518. extern unsigned char TABO_Nx;
  519. /*--------------------------- local data ------------------------------*/
  520. #define TABO_PARAMS  2
  521.  unsigned char *word[TABO_PARAMS+1];
  522.  char parm[TABO_PARAMS];
  523.  register int i;
  524.  unsigned short num_params;
  525.  unsigned short x,y;
  526.  char pre_col;
  527.  short rc;
  528. /*--------------------------- processing ------------------------------*/
  529. #ifdef TRACE
  530.  trace_function("comm5.c:   Tabsout");
  531. #endif
  532.  num_params = param_split(params,word,TABO_PARAMS);
  533.  for (i=0;i<TABO_PARAMS;i++)
  534.      parm[0] = UNDEFINED_OPERAND;
  535.  if (equal("on",word[0],2))
  536.     parm[0] = TRUE;
  537.  if (equal("off",word[0],3))
  538.     parm[0] = FALSE;
  539.  if (parm[0] == UNDEFINED_OPERAND)
  540.    {
  541.     display_error(1,word[0]);
  542. #ifdef TRACE
  543.     trace_return();
  544. #endif
  545.     return(OK);
  546.    }
  547.  switch(parm[0])
  548.     {
  549.      case TRUE:
  550.          if (!valid_positive_integer(word[1]))
  551.            {
  552.             display_error(4,word[1]);
  553. #ifdef TRACE
  554.             trace_return();
  555. #endif
  556.             return(OK);
  557.            }
  558.          parm[1] = (char)atoi(word[1]);
  559.          break;
  560.      case FALSE:
  561.          if (strcmp(word[1],"") != 0)
  562.             {
  563.              display_error(1,word[1]);
  564. #ifdef TRACE
  565.             trace_return();
  566. #endif
  567.              return(OK);
  568.             }
  569.          break;
  570.     }
  571.  if (parm[0])
  572.    {
  573.     if (parm[1] < 1)
  574.       {
  575.        display_error(5,word[1]);
  576. #ifdef TRACE
  577.        trace_return();
  578. #endif
  579.        return(OK);
  580.       }
  581.     if (parm[1] > 32)
  582.       {
  583.        display_error(6,word[1]);
  584. #ifdef TRACE
  585.        trace_return();
  586. #endif
  587.        return(OK);
  588.       }
  589.    }
  590.  if (in_profile)
  591.    {
  592.     TABO_ONx = parm[0];
  593.     TABO_Nx = parm[1];
  594.    }
  595.  else
  596.    {
  597.     CURRENT_FILE->tabsout_on = parm[0];
  598.     CURRENT_FILE->tabsout_num = parm[1];
  599.    }
  600. #ifdef TRACE
  601.  trace_return();
  602. #endif
  603.  return(OK);
  604. }
  605. /*man-start*********************************************************************
  606. COMMAND
  607.      top - move to the top of the file
  608.  
  609. SYNTAX
  610.      TOP
  611.  
  612. DESCRIPTION
  613.      The TOP command moves to the very start of the current file.
  614.      The "Top-of-file" line is set to the current_line.
  615.  
  616.      "TOP" is equivalent to "BACKWARD *".
  617.  
  618. COMPATIBILITY
  619.      Compatible.
  620.  
  621. SEE ALSO
  622.      backward,bottom
  623.  
  624. STATUS
  625.      Complete
  626. **man-end**********************************************************************/
  627. #ifdef PROTO
  628. int Top(unsigned char *params)
  629. #else
  630. int Top(params)
  631. unsigned char *params;
  632. #endif
  633. /***********************************************************************/
  634. {
  635. /*--------------------------- local data ------------------------------*/
  636.  short rc;
  637. /*--------------------------- processing ------------------------------*/
  638. #ifdef TRACE
  639.  trace_function("comm5.c:   Top");
  640. #endif
  641.  rc = Backward("*");
  642. #ifdef TRACE
  643.  trace_return();
  644. #endif
  645.  return(rc);
  646. }
  647. /*man-start*********************************************************************
  648. COMMAND
  649.      up - move backward in the file a number of lines
  650.  
  651. SYNTAX
  652.      Up [target]
  653.  
  654. DESCRIPTION
  655.      The UP command moves the current_line backwards the number of
  656.      lines specified by the target. Negative targets move forwards
  657.      through the file.
  658.  
  659. COMPATIBILITY
  660.      Compatible.
  661.  
  662. SEE ALSO
  663.      Next
  664.  
  665. STATUS
  666.      Complete.
  667. **man-end**********************************************************************/
  668. #ifdef PROTO
  669. int Up(unsigned char *params)
  670. #else
  671. int Up(params)
  672. unsigned char *params;
  673. #endif
  674. /***********************************************************************/
  675. {
  676. /*--------------------------- local data ------------------------------*/
  677. #define UP_PARAMS  1
  678.  unsigned char *word[UP_PARAMS+1];
  679.  unsigned short num_params;
  680.  long num_lines;
  681.  unsigned short y,x;
  682.  unsigned char cmd_line[10];
  683. /*--------------------------- processing ------------------------------*/
  684. #ifdef TRACE
  685.  trace_function("comm5.c:   Up");
  686. #endif
  687.  num_params = param_split(params,word,UP_PARAMS);
  688.  if (num_params == 0)
  689.    {
  690.     num_params = 1;
  691.     word[0] = (unsigned char *)"1";
  692.    }
  693.  if (num_params != 1)
  694.    {
  695.     display_error(1,word[1]);
  696. #ifdef TRACE
  697.     trace_return();
  698. #endif
  699.     return(OK);
  700.    }
  701.  if ((num_lines = valid_target(word[0])) == TARGET_ERROR)
  702.    {
  703.     display_error(4,word[0]);
  704. #ifdef TRACE
  705.     trace_return();
  706. #endif
  707.     return(OK);
  708.    }
  709.  
  710.  sprintf(cmd_line,"%-ld",num_lines*(-1));
  711.  Next(cmd_line);
  712. #ifdef TRACE
  713.  trace_return();
  714. #endif
  715.  return(OK);
  716. }
  717. /*man-start*********************************************************************
  718. COMMAND
  719.      up_arrow - move the cursor up one line
  720.  
  721. SYNTAX
  722.      ** effective only if bound to a key **
  723.  
  724. DESCRIPTION
  725.      The up_arrow command moves the cursor up one line in the main
  726.      window. Scrolling of the window occurs if the cursor is on the first
  727.      line of the window.
  728.  
  729.      When on the command line, this command moves backward through the
  730.      list of previous command line commands or tabs to the last line of
  731.      the main window depending on the value set by the function
  732.      cmdarrows. (default is the former)
  733.  
  734. COMPATIBILITY
  735.      Compatible.
  736.  
  737. SEE ALSO
  738.      Down_arrow
  739.  
  740. STATUS
  741.      Complete.
  742. **man-end**********************************************************************/
  743. #ifdef PROTO
  744. int Up_arrow(unsigned char *params)
  745. #else
  746. int Up_arrow(params)
  747. unsigned char *params;
  748. #endif
  749. /***********************************************************************/
  750. {
  751. /*------------------------- external data -----------------------------*/
  752. extern unsigned char CMDARROWSTABx;
  753. /*--------------------------- local data ------------------------------*/
  754.  unsigned short x,y;
  755. /*--------------------------- processing ------------------------------*/
  756. #ifdef TRACE
  757.  trace_function("comm5.c:   Up_arrow");
  758. #endif
  759.  switch(CURRENT_VIEW->current_window)
  760.   {
  761.    case WINDOW_MAIN:
  762.    case WINDOW_PREFIX:
  763.         getyx(CURRENT_WINDOW,y,x);
  764. /*---------------------------------------------------------------------*/
  765. /* If the cursor is on the first line of the file...                   */
  766. /* ... and the first line of the file is on the current row, stay there.*/
  767. /*---------------------------------------------------------------------*/
  768.         if (CURRENT_VIEW->current_line == 0
  769.         && y == CURRENT_VIEW->current_row)
  770.            break;
  771. /*---------------------------------------------------------------------*/
  772. /* If the cursor is on the first line of the file...                   */
  773. /* ... and the first line of the file is above the current row,        */
  774. /* scroll the window down one line.                                    */
  775. /*---------------------------------------------------------------------*/
  776.         if (CURRENT_VIEW->current_line+y
  777.             == CURRENT_VIEW->current_row)
  778.            {
  779.             CURRENT_VIEW->current_line--;
  780.             show_page();
  781.             wmove(CURRENT_WINDOW,y+1,x);
  782.             break;
  783.            }
  784. /*---------------------------------------------------------------------*/
  785. /* If on the top line of the window, scroll the window down 1 line.    */
  786. /*---------------------------------------------------------------------*/
  787.         if (y == 0)
  788.            {
  789.             CURRENT_VIEW->current_line--;
  790.             post_process_line(CURRENT_VIEW->focus_line);
  791.             CURRENT_VIEW->focus_line--;
  792.             pre_process_line(CURRENT_VIEW->focus_line);
  793.             show_page();
  794.             wmove(CURRENT_WINDOW,y,x);
  795.             break;
  796.            }
  797. /*---------------------------------------------------------------------*/
  798. /* We are in the middle of the window, so just move the cursor up      */
  799. /* 1 line.                                                             */
  800. /*---------------------------------------------------------------------*/
  801.         wmove(CURRENT_WINDOW,y-1,x);
  802.         post_process_line(CURRENT_VIEW->focus_line);
  803.         CURRENT_VIEW->focus_line--;
  804.         pre_process_line(CURRENT_VIEW->focus_line);
  805.         break;
  806.    case WINDOW_COMMAND:
  807. /*---------------------------------------------------------------------*/
  808. /* Cycle backward through the command list or tab to last line.        */
  809. /*---------------------------------------------------------------------*/
  810.         if (CMDARROWSTABx)
  811.           {
  812.            getyx(CURRENT_WINDOW,y,x);
  813.            if (CURRENT_VIEW->prefix_on != TRUE
  814.            ||  CURRENT_VIEW->prefix_left != TRUE)
  815.               x += 6;
  816.            if (CURRENT_FILE->number_lines >= CURRENT_SCREEN.rows -
  817.                                            CURRENT_VIEW->current_row +
  818.                                            CURRENT_VIEW->current_line - 1)
  819.              {
  820.               CURRENT_VIEW->focus_line = CURRENT_SCREEN.rows -
  821.                                         CURRENT_VIEW->current_row +
  822.                                         CURRENT_VIEW->current_line - 1;
  823.               y = CURRENT_SCREEN.rows -1;
  824.              }
  825.            else
  826.              {
  827.               CURRENT_VIEW->focus_line = CURRENT_FILE->number_lines + 1;
  828.               y = get_row_for_focus_line(CURRENT_VIEW->current_row,
  829.                                          CURRENT_VIEW->focus_line,
  830.                                          CURRENT_VIEW->current_line);
  831.              }
  832.            pre_process_line(CURRENT_VIEW->focus_line);
  833.            CURRENT_VIEW->current_window = WINDOW_MAIN;
  834.            wmove(CURRENT_WINDOW,y,x);
  835.           }
  836.         else
  837.            Retrieve("");
  838.         break;
  839.    default:
  840.         display_error(2,"");
  841.         break;
  842.   }
  843. #ifdef TRACE
  844.  trace_return();
  845. #endif
  846.  return(OK);
  847. }
  848. /*man-start*********************************************************************
  849. COMMAND
  850.      verify - set column display limits
  851.  
  852. SYNTAX
  853.      Verify first [last]
  854.  
  855. DESCRIPTION
  856.      The VERIFY command sets the column limits for the display of the
  857.      current file. 'first' specifies the first column to be displayed
  858.      and 'last' specifies the last column to be displayed.
  859.  
  860.      If no 'last' option is specified '*' is assumed.
  861.  
  862. COMPATIBILITY
  863.      Does not implement HEX display nor multiple column pairs.
  864.  
  865. SEE ALSO
  866.      Zone
  867.  
  868. STATUS
  869.      Complete.
  870. **man-end**********************************************************************/
  871. #ifdef PROTO
  872. int Verify(unsigned char *params)
  873. #else
  874. int Verify(params)
  875. unsigned char *params;
  876. #endif
  877. /***********************************************************************/
  878. {
  879. /*--------------------------- extern data -----------------------------*/
  880.  unsigned short VER_STAx;
  881.  unsigned short VER_COLx;
  882.  unsigned short VER_ENDx;
  883. /*--------------------------- local data ------------------------------*/
  884. #define VER_PARAMS  2
  885.  unsigned char *word[VER_PARAMS+1];
  886.  unsigned short num_params;
  887.  long col1,col2;
  888.  unsigned short x,y;
  889. /*--------------------------- processing ------------------------------*/
  890. #ifdef TRACE
  891.  trace_function("comm5.c:   Verify");
  892. #endif
  893. /*---------------------------------------------------------------------*/
  894. /* Validate the parameters that have been supplied. One or two         */
  895. /* parameters can be supplied. The first parameter MUST be a positive  */
  896. /* integer. The second can be a positive integer or '*'. If no second  */
  897. /* parameter is supplied, '*' is assumed. The second parameter MUST be */
  898. /* >= first parameter. '*' is regarded as the biggest number and is    */
  899. /* literally MAX_LINE_LENGTH.                                          */
  900. /*---------------------------------------------------------------------*/
  901.  num_params = param_split(params,word,VER_PARAMS);
  902.  if (num_params == 0)
  903.    {
  904.     display_error(3,"");
  905. #ifdef TRACE
  906.     trace_return();
  907. #endif
  908.     return(OK);
  909.    }
  910.  if (num_params > 2)
  911.    {
  912.     display_error(2,"");
  913. #ifdef TRACE
  914.     trace_return();
  915. #endif
  916.     return(OK);
  917.    }
  918.  if (valid_positive_integer(word[0]) == TARGET_ERROR)
  919.    {
  920.     display_error(4,word[0]);
  921. #ifdef TRACE
  922.     trace_return();
  923. #endif
  924.     return(OK);
  925.    }
  926.  col1 = atol(word[0]);
  927.  if (num_params == 1)
  928.      col2 = MAX_LINE_LENGTH;
  929.  else
  930.      if (strcmp(word[1],"*") == 0)
  931.         col2 = MAX_LINE_LENGTH;
  932.      else
  933.         if (valid_positive_integer(word[1]) == TARGET_ERROR)
  934.           {
  935.            display_error(4,word[1]);
  936. #ifdef TRACE
  937.            trace_return();
  938. #endif
  939.            return(OK);
  940.           }
  941.         else
  942.            col2 = atol(word[1]);
  943.  
  944.  if (col2 > MAX_LINE_LENGTH)
  945.     col2 = MAX_LINE_LENGTH;
  946.  if (col1 > col2)
  947.    {
  948.     display_error(6,word[0]);
  949. #ifdef TRACE
  950.     trace_return();
  951. #endif
  952.     return(OK);
  953.    }
  954.  if (in_profile)
  955.    {
  956.     VER_STAx = col1;
  957.     VER_COLx = col1;
  958.     VER_ENDx = col2;
  959.    }
  960.  else
  961.    {
  962.     CURRENT_VIEW->verify_start = col1;
  963.     CURRENT_VIEW->verify_col = col1;
  964.     CURRENT_VIEW->verify_end   = col2;
  965.     getyx(CURRENT_WINDOW,y,x);
  966.     show_page();
  967.     if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  968.        wmove(CURRENT_WINDOW,y,x);
  969.    }
  970. #ifdef TRACE
  971.  trace_return();
  972. #endif
  973.  return(OK);
  974. }
  975. /*man-start*********************************************************************
  976. COMMAND
  977.      zone - set column limits for editting
  978.  
  979. SYNTAX
  980.      Zone first [last]
  981.  
  982. DESCRIPTION
  983.      The ZONE command sets the column limits for various other editor
  984.      commands, such as 'locate' and 'change'. It effectively restricts
  985.      the editable (?) portion of the file to the specified columns.
  986.  
  987.      If no 'last' option is specified '*' is assumed.
  988.  
  989. COMPATIBILITY
  990.      Compatible.
  991.  
  992. SEE ALSO
  993.      Verify
  994.  
  995. STATUS
  996.      Complete.
  997. **man-end**********************************************************************/
  998. #ifdef PROTO
  999. int Zone(unsigned char *params)
  1000. #else
  1001. int Zone(params)
  1002. unsigned char *params;
  1003. #endif
  1004. /***********************************************************************/
  1005. {
  1006. /*--------------------------- extern data -----------------------------*/
  1007.  extern unsigned short ZON_STAx;
  1008.  extern unsigned short ZON_ENDx;
  1009.  extern unsigned char file_read; /* indicates if we have read the file */
  1010. /*--------------------------- local data ------------------------------*/
  1011. #define ZON_PARAMS  2
  1012.  unsigned char *word[ZON_PARAMS+1];
  1013.  unsigned short num_params;
  1014.  long col1,col2;
  1015.  unsigned short x,y;
  1016. /*--------------------------- processing ------------------------------*/
  1017. #ifdef TRACE
  1018.  trace_function("comm5.c:   Zone");
  1019. #endif
  1020. /*---------------------------------------------------------------------*/
  1021. /* Validate the parameters that have been supplied. One only           */
  1022. /* parameter MUST be supplied. The first parameter MUST be a positive  */
  1023. /* integer. The second can be a positive integer or '*'. If no second  */
  1024. /* parameter is supplied, ERROR.          The second parameter MUST be */
  1025. /* >= first parameter. '*' is regarded as the biggest number and is    */
  1026. /* literally MAX_LINE_LENGTH.                                          */
  1027. /*---------------------------------------------------------------------*/
  1028.  num_params = param_split(params,word,ZON_PARAMS);
  1029.  if (num_params < 2)
  1030.    {
  1031.     display_error(3,"");
  1032. #ifdef TRACE
  1033.     trace_return();
  1034. #endif
  1035.     return(OK);
  1036.    }
  1037.  if (num_params > 2)
  1038.    {
  1039.     display_error(2,"");
  1040. #ifdef TRACE
  1041.     trace_return();
  1042. #endif
  1043.     return(OK);
  1044.    }
  1045.  if (valid_positive_integer(word[0]) == TARGET_ERROR)
  1046.    {
  1047.     display_error(4,word[0]);
  1048. #ifdef TRACE
  1049.     trace_return();
  1050. #endif
  1051.     return(OK);
  1052.    }
  1053.  col1 = atol(word[0]);
  1054.  if (strcmp(word[1],"*") == 0)
  1055.     col2 = MAX_LINE_LENGTH;
  1056.  else
  1057.     if (valid_positive_integer(word[1]) == TARGET_ERROR)
  1058.       {
  1059.        display_error(4,word[1]);
  1060. #ifdef TRACE
  1061.        trace_return();
  1062. #endif
  1063.        return(OK);
  1064.       }
  1065.     else
  1066.        col2 = atol(word[1]);
  1067.  
  1068.  if (col2 > MAX_LINE_LENGTH)
  1069.     col2 = MAX_LINE_LENGTH;
  1070.  if (col1 > col2)
  1071.    {
  1072.     display_error(6,word[0]);
  1073. #ifdef TRACE
  1074.     trace_return();
  1075. #endif
  1076.     return(OK);
  1077.    }
  1078.  if (file_read)
  1079.    {
  1080.     CURRENT_VIEW->zone_start = col1;
  1081.     CURRENT_VIEW->zone_end   = col2;
  1082.    }
  1083.  else
  1084.    {
  1085.     ZON_STAx = col1;
  1086.     ZON_ENDx = col2;
  1087.    }
  1088. #ifdef TRACE
  1089.  trace_return();
  1090. #endif
  1091.  return(OK);
  1092. }
  1093.